//
//  AlbumHomeTableViewController.swift
//  Media
//
//  Created by han on 2021/6/8.
//

import UIKit

class AlbumHomeTableViewController: UITableViewController {
    var dataSource = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        dataSource = [
            "调用系统相册选择器",
            "相册列表",
        ];
    }
}

extension AlbumHomeTableViewController {
    override func numberOfSections(in tableView: UITableView) -> Int { 1 }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { self.dataSource.count }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: HomeCell.identifier, for: indexPath) as? HomeCell
        cell?.titleLabel.text = dataSource[indexPath.row]
        return cell ?? UITableViewCell()
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        switch indexPath.row {
        case 0: // 系统相册选择器
            performSegue(withIdentifier: "nativePicker", sender: nil)
        /*
          // TODO: 调用系统picker
         AlbumNativePickerViewController
         livePhoto保存
         PHPicker 拍照
         PHPicker 编辑图片
         */
        case 1: // 相册列表
        performSegue(withIdentifier: "AlbumList", sender: nil)
            break
        default:
            break
        }
    }
}


